<%@page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>预算报价单</title>
<%@ include file="../../common/common.jsp"%>

	
<script type="text/javascript">


function pro_statusFormatter(value,row,index){
	if (value==0){
		var s = '未编制';
		return s;
	}
	if (value==1){
		var s = '已编制';
		return s;
	}
	if (value==2){
		var s = '已审核';
		return s;
	}
}


//初始化项目信息
$(function(){
	$('#dg').datagrid({
		view: detailview,
		detailFormatter:function(index,row){
			return '<div style="padding:2px"><table id="ddv-' + index + '"></table></div>';
		},
		onExpandRow: function(index,row){
			
			$('#ddv-'+index).datagrid({
				url:'<%=basePath%>loadProWorkDetailAction.do?projectWorkInfo.projectinfo_id='+row.id,
				fitColumns:true,
				singleSelect:true,
				height:'auto',
				width:'600',
				columns:[[
					{field:'cesspoolNo',title:'化粪池编号',width:20},
					{field:'cesspoolDoPerson',title:'施工分队',width:20},
					{field:'cesspoolType',title:'类型',width:20},
					{field:'cesspoolDoContent',title:'工程内容',width:40},									
					{field:'cesspoolBudgetPrice',title:'预算价',width:30}
					
				]],
				onResize:function(){
					$('#dg').datagrid('fixDetailRowHeight',index);
				},
				onLoadSuccess:function(){
					setTimeout(function(){
						$('#dg').datagrid('fixDetailRowHeight',index);
					},0);
				}
			});
			$('#dg').datagrid('fixDetailRowHeight',index);
		}
	});
});
	
		
//报价单
function sheet_info(){
	
		var selected = $("#dg").datagrid("getSelected");
		//alert(selected.id);
	
		var url = "<%=basePath%>budgetSheetAction.do?projectInfo.id="+selected.id;
		
		//window.open(url, '','width=790,height=590');
		
 $('<div><iframe frameborder="0" scrolling="yes" marginheight="0" framespacing=0 marginwidth="0" '+
		'"FrameBorder=0 src="'+url+'" style="width:100%;height:95%; "/></div>').dialog({			
			open : function() {
			},
			height : 450,
			width : 800,
			title : '报价单',
			resizable:true,
			maximizable:true

		}); 
}


	

//查询
function search_data(){	
	var ct_name =$("#ct_name").attr('value');
	var d_start = $("#dd1").datebox("getText");
	var d_end= $("#dd2").datebox("getText");
	
	var url = "<%=basePath%>loadProjectInfoAction.do?projectInfo.projectStatus=2&projectInfo.projectName="+ct_name+"&projectInfo.query_startTime="+d_start+"&projectInfo.query_endTime="+d_end;
	var params = {} ;
	jQuery.post(url,params,function(data){
		//alert(data);
		$('#dg').datagrid("loadData",data);
	
	},'json');
}

$(document).ready(function(){
	
	$(function(){
		$('#dd1').datebox({
		    formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();},
		    parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));}
		});
		$('#dd2').datebox({
		    formatter: function(date){ return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();},
		    parser: function(date){ return new Date(Date.parse(date.replace(/-/g,"/")));}
		});
	})
	
	
})

	
</script>
	

</head>
<body>

	<div id="toolbar">
			<a href="#" class="easyui-linkbutton" iconCls="icon-ok" 
				onclick="sheet_info()">报价单</a>
	</div>
	
	<table width="1100px"  height="20px" style="text-align:center;background:#f3eeaf;border:1px solid #b3dfda">
				<tr>
					<td width="60">日期 :</td>
					<td><input class="easyui-datebox" style="width:100px" id="dd1">至: <input class="easyui-datebox" style="width:100px" id="dd2"></td>
					<td width="60">项目名称: </td>
					<td><input  style="width:150px" id="ct_name" name="ct_name"></td>
					<td><a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-search" onclick="search_data()">查询</a></td>
				</tr>		
	</<table>
	
	<table id="dg" style="width:1100px;height:350px"
			url="<%=basePath %>loadProjectInfoAction.do?projectInfo.projectStatus=2" 
			title="项目信息"
			singleSelect="true" fitColumns="true" pagination = "true" toolbar="#toolbar" >
		<thead>
			<tr>
				<th field="contractinfo_name" width="40" align="center" >所属合同名称</th>
				<th field="projectName" align="center" width="40">项目名称</th>
				<th field="constructionOrganization" align="center" width="18">施工单位</th>
				<th field="constructionAddr" align="center" width="18">施工地点</th>
				<th field="pipeLength" width="18" >管道长度</th>
				<th field="managerCompanyInfo" width="20" align="center">物管信息</th>
				<th field="residentCount" width="15" align="center">总户数</th>
				<th field="buildArea" width="15" align="center">总面积</th>
				<th field="pitCount" width="18" align="center">化粪池数</th>
				<th field="budgetPrice" width="22" align="center">项目预算价</th>
				<th field="contractPrice" width="22" align="center">项目合同价</th>
				<th field="createTime" width="18" align="center">创建时间</th>
				<th field=projectStatus width="15" align="center" formatter="pro_statusFormatter" >状态</th>
				<th field="projectSpec" width="30" align="center">项目说明</th>
			</tr>
		</thead>
	</table>
	
	
		
	
</body>
</html>